import sqlite3

# 插入多条数据
con = sqlite3.connect("db1.db")

sql = 'insert into t_person(pname,age) values(?,?)'

cursor = con.cursor()

try:
    cursor.executemany(sql, [("李斯2", 19), ("李斯3", 18), ("李斯4", 16), ("李斯5", 20)])
    con.commit()
    print("插入数据成功")
except Exception as e:
    print(e)
    print("插入数据失败")
    con.rollback()
finally:
    cursor.close()
    con.close()

# print(con)
